﻿using System;
using System.IO;

namespace WinPaper
{
    class Program
    {
        static string datapath = Environment.GetEnvironmentVariable("AppData");

        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(Directory.GetParent(datapath).FullName);
            datapath = Directory.GetCurrentDirectory();

            string path = datapath + @"\Local\Packages\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\LocalState\Assets";
            string target = AppDomain.CurrentDomain.BaseDirectory + @"WallPapers\";

            //新建文件夹
            if (Directory.Exists(target))
            {
                DirectoryInfo f = new DirectoryInfo(target);
                foreach (FileInfo file in f.GetFiles())
                {
                    file.Delete();
                }
            }
            Directory.CreateDirectory(target);

            //实例化文件夹
            DirectoryInfo Folder = new DirectoryInfo(path);
            //遍历文件
            foreach (FileInfo file in Folder.GetFiles())
            {
                //移动文件
                File.Copy(file.FullName, target + file.Name + ".jpg");
            }

        }
    }
}
